import { DramaEffectInfo } from "./info/DramaEffectInfo";
import { StringUtil } from "../../../mx/utils/StringUtil";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
//class DramaEffectConfig
    
    export  class DramaEffectConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (DramaEffectConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1.drama;
            for(loc2 of loc4) 
            {
                loc1 = new DramaEffectInfo();
                loc1.code = loc2.code;
                loc1.src = loc2.src;
                loc1.points = this.toPointArray(loc2.points);
                loc1.moveType = this.toNumberArray(loc2.moveType);
                loc1.moveTime = this.toNumberArray(loc2.moveTime);
                loc1.repeatCount = loc2.repeatCount;
                loc1.repeatInterval = loc2.repeatInterval;
                loc1.sound = loc2.sound;
                loc1.scaleX = this.toNumberArray(loc2.scaleX);
                loc1.scaleY = this.toNumberArray(loc2.scaleY);
                loc1.delay = loc2.delay;
                loc1.effectType = loc2.effectType;
                this._map[loc2.code] = loc1;
            }
            return;
        }

        /* internal  */toPointArray(arg1: string): Array<any>
        {
            var loc2=null;
            var loc3=0;
            var loc4=null;
            var loc5=null;
            arg1 = StringUtil.trim(arg1);
            var loc1=[];
            if (arg1.length > 2) 
            {
                arg1 = arg1.substring(1, (arg1.length - 1));
                loc2 = arg1.split("),(");
                loc3 = 0;
                while (loc3 < loc2.length) 
                {
                    loc4 = loc2[loc3];
                    if ((loc5 = this.toNumberArray(loc4)).length == 2) 
                    {
                        loc1.push(new Object /* flash.geom.Point */(loc5[0], loc5[1]));
                    }
                    ++loc3;
                }
            }
            return loc1;
        }

        /* internal  */toNumberArray(arg1: string): Array<any>
        {
            arg1 = StringUtil.trim(arg1);
            var loc1=arg1.split(",");
            var loc2=[];
            var loc3=0;
            while (loc3 < loc1.length) 
            {
                loc2.push(Number(loc1[loc3]));
                ++loc3;
            }
            return loc2;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getObjectByFileName("dramaEffect.xml");
            this.write(loc1);
            return;
        }

        public getDramaEffectInfo(arg1: Object): DramaEffectInfo
        {
            return this._map[arg1];
        }

        public static get instance(): DramaEffectConfig
        {
            if (DramaEffectConfig._instance == null) 
            {
                DramaEffectConfig._instance = new DramaEffectConfig();
            }
            return DramaEffectConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: DramaEffectConfig;
    }
